package com.learn.postprocessor.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.Ordered;

/**
 *
 * @author daify
 * @date 2019-03-26 17:38
 **/
public class BeanFactoryPostProcessorTest2 implements 
                                          BeanFactoryPostProcessor, Ordered {
    @Override public void postProcessBeanFactory(
            ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("调用 BeanFactoryPostProcessorTest2 ...");

        // 获取指定的 BeanDefinition
        BeanDefinition bd = beanFactory.getBeanDefinition("postProcessorTest");

        MutablePropertyValues pvs = bd.getPropertyValues();

        pvs.addPropertyValue("id",5);
    }

    @Override public int getOrder() {
        return 2;
    }
}
